package cn.study.luckyapp.record.command;

import cn.study.luckyapp.assembler.RecordAssembler;
import cn.study.luckyclient.dto.RecordAddCmd;
import cn.study.luckyclient.dto.data.RecordVo;
import cn.study.luckydomain.gateway.RecordGateWay;
import cn.study.luckydomain.record.RecordEntity;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@AllArgsConstructor
public class RecordAddCmdExe {
    private final RecordGateWay recordGateway;

    public RecordVo execute(RecordAddCmd cmd) {
        RecordEntity entity = recordGateway.save(RecordAssembler.toAddEntity(cmd));

        return RecordAssembler.toRecordVO(entity);
    }
}
